package com.daily.taskcenter.tasks;

import com.daily.taskcenter.anno.RegisterTask;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.math.RandomUtils;
import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author z
 * @date 2019/7/25 12:38
 **/
@Component
@Slf4j
public class TestDyTask2 implements DyTask {

    /**
     * 启动后，不自动将信息注入到数据库
     */
    @RegisterTask(enable = false, name = "testDyTask2")
    @Override
    public ReturnT<String> run() {

        log.info("TestDyTask2 测试任务");

        long l = RandomUtils.nextLong();

        if(l % 5 == 0) {
            throw new RuntimeException("执行器内部逻辑发现异常");
        }

        if(l % 3 == 0) {
            return ReturnT.FAIL;
        } else {
            return ReturnT.SUCCESS;
        }

    }
}
